<template>
  <!--<div class="login" :style="'background-image:url('+ Background +');'">-->
  <div class="login" style="background-color: rgba(13, 181, 200, 1)">
    <el-form ref="loginForm"  label-position="left" label-width="0px" class="login-form">
      <h3 class="title">
        zuosx-admin 后台管理系统
      </h3>
      <el-form-item prop="username">
        <el-input v-model="username" type="text" auto-complete="off" placeholder="账号">
          <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon"/>
        </el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input v-model="password" type="password" auto-complete="off" placeholder="密码">
          <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/>
        </el-input>
      </el-form-item>
      <el-form-item prop="code">
        <el-input v-model="code" auto-complete="off" placeholder="验证码" style="width: 63%">
          <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon"/>
        </el-input>
      </el-form-item>
      <el-checkbox v-model="rememberMe" style="margin:0 0 25px 0;">
        记住我
      </el-checkbox>
      <el-form-item style="width:100%;">
        <el-button size="medium" type="primary"
                   style="width:100%;background-color: rgba(13, 181, 200, 1);border-color:rgba(13, 181, 200, 1)"
                   @click.native.prevent="handleLogin">
          <span>登 录</span>
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import Background from '@/assets/images/background.jpg'

export default {
  name: 'Login',
  data() {
    return {
      Background: Background,
      username: 'admin',
      password: 'admin',
      code: '1234',
      rememberMe: false
    }
  },
  methods: {
    handleLogin() {
      var param = {
        username: this.username,
        password: this.password
      };
      this.commonRequest.login(this, param, (res) => {
        sessionStorage.setItem("tokenInfo", JSON.stringify(res.data));
        this.$router.push('/');
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-size: cover;
}

.title {
  margin: 0 auto 30px auto;
  text-align: center;
  color: #707070;
}

.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: 385px;
  padding: 25px 25px 5px 25px;

  .el-input {
    height: 38px;

    input {
      height: 38px;
    }
  }

  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}

.login-tip {
  font-size: 13px;
  text-align: center;
  color: #17a2b8;
}

.login-code {
  width: 33%;
  display: inline-block;
  height: 38px;
  float: right;

  img {
    cursor: pointer;
    vertical-align: middle
  }
}
</style>
